import { _decorator, Vec3 } from 'cc';
import { BaseSkill } from './BaseSkill';
import { CharacterController } from '../controllers/CharacterController';
import { EvolutionSkills } from '../config/EvolutionConfig';
import { EffectSystem } from '../systems/EffectSystem';
import { AudioSystem } from '../systems/AudioSystem';
import { AudioConfig } from '../config/AudioConfig';

const { ccclass, property } = _decorator;

@ccclass('DashSkill')
export class DashSkill extends BaseSkill {
    @property(CharacterController)
    private characterController: CharacterController | null = null;

    @property(EffectSystem)
    private effectSystem: EffectSystem | null = null;

    private originalSpeed: number = 0;
    private readonly speedBoost: number = EvolutionSkills.dash.speedBoost;

    start() {
        this.cooldown = EvolutionSkills.dash.cooldown;
        this.duration = EvolutionSkills.dash.duration;
    }

    protected onActivate(): void {
        if (!this.characterController) return;

        this.originalSpeed = this.characterController.moveSpeed;
        this.characterController.moveSpeed *= this.speedBoost;

        // 播放冲刺特效
        if (this.effectSystem) {
            this.effectSystem.playEffect('DashEffect', this.node.position, this.node.eulerAngles.z);
        }

        // 播放冲刺音效（音量稍微调低）
        AudioSystem.instance.playEffect(AudioConfig.EFFECTS.DASH, 0.8);
    }

    protected onDeactivate(): void {
        if (!this.characterController) return;
        
        this.characterController.moveSpeed = this.originalSpeed;
    }
} 